package com.ruoyi.web.controller.vantController.customerController;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.customer.LocalFabulous;
import com.ruoyi.system.domain.customer.LocalReviers;
import com.ruoyi.system.domain.zhuangxiumain.vo.ResviersVo;
import com.ruoyi.system.service.vantservice.customerervice.ApiLocalFabulousService;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.ws.rs.POST;
import java.util.Map;

/**
 * Created by 惠普 on 2020/12/30 17:32
 */
@RestController
@RequestMapping("/api/local/fabulous")
public class ApiLocalFabulousController {
    @Resource
    private ApiLocalFabulousService apiLocalFabulousService;

    /**
     * 点赞
     * @param localFabulous
     * @return
     */
    @PostMapping("/jiaLocalFabulous")
    public AjaxResult jiaLocalFabulous(@RequestBody LocalFabulous localFabulous){
        return AjaxResult.success(apiLocalFabulousService.addLocalFabulous(localFabulous));
    }

    /**
     * 点赞1
     * @param localFabulous
     * @return
     */
    @PostMapping("/jia1LocalFabulous")
    public AjaxResult jia1LocalFabulous(@RequestBody LocalFabulous localFabulous){
        return AjaxResult.success(apiLocalFabulousService.updateLocalFabulous(localFabulous));
    }

    /**
     * 取消赞
     * @param localFabulous
     * @return
     */
    @PostMapping("/jianLocalFabulous")
    public AjaxResult jianLocalFabulous(@RequestBody LocalFabulous localFabulous){
        return AjaxResult.success(apiLocalFabulousService.updateLocalFabulous(localFabulous));
    }

    /**
     * 我的页面发布信息数量显示
     * @return
     */
    @PostMapping("/releaseShu")
    public Integer releaseShu(){
        return apiLocalFabulousService.selectLocalReviersByCustomerId();
    }

    /**
     * 用户发布本地信息
     * @return
     */
    @PostMapping("/addReviersByCustomer")
    public AjaxResult addReviersByCustomer(@RequestBody LocalReviers localReviers){
        System.out.println("ww wwwwwwwwwwwwwwwwwww"+localReviers);
        return AjaxResult.success(apiLocalFabulousService.addReviersByCustomer(localReviers));
    }

    /**
     * 查询用户本地发布的全部信息
     * @return
     */
    @PostMapping("/selectResviersByCustomer")
    public AjaxResult selectResviersByCustomer(@RequestBody ResviersVo resviersVo){
        return AjaxResult.success(apiLocalFabulousService.selectResviersByCustomer(resviersVo));
    }

    /**
     *多图片上传
     * @param files
     */
    @PostMapping("/upload")
    public Map<String, Object> up(@RequestParam("files")MultipartFile[] files) {
        return apiLocalFabulousService.uploadImages(files);
    }

    /**
     * 用户的点赞数查询
     * @return
     */
    @PostMapping("/fabulousShu")
    public Integer fabulousShu(){
        return apiLocalFabulousService.selectLocalFabulousByCustomerId();
    }




}
